package com.google.location.im.ui;


import java.util.Hashtable;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;

import de.enough.polish.ui.Form;
import de.enough.polish.ui.TextField;
import de.enough.polish.util.Locale;

/**
 *
 * @author tharindu
 */
public class SearchScreen extends Form implements javax.microedition.lcdui.CommandListener {
    private MainUI ui_;
    private Hashtable commands_;

    private boolean valid;

    //#style textfieldItem
    final private TextField location_ = new TextField(Locale.get("locateim.search.location"), "Kandy", 10, TextField.NUMERIC);//[LOCALE]
    //#style textfieldItem
    final private TextField friend_ = new TextField(Locale.get("locateim.search.friend"), "", 10, TextField.NUMERIC|TextField.PASSWORD);//[LOCALE]

    public SearchScreen() {

        //#style ftScreen
        super(Locale.get("locateim.search.title")); //[LOCALE]

        ui_ = MainUI.getInstance();
        commands_ = ui_.getCommands();

        try {
            setCommandListener(this);
        } catch (Exception e) {
            e.printStackTrace();
        }
        addCommand((Command) commands_.get(new Integer(MainUI.CMD_OK)));
        addCommand((Command) commands_.get(new Integer(MainUI.CMD_EXIT)));

        this.append( location_ );
        this.append( friend_ );

    }

    public boolean isValidInput() {
        valid = false;
        if( location_.getText().length()!=0 || friend_.getText().length()!=0) {
            valid = true;
        }
        return valid;
    }

    public String getLocation() {
        return location_.getText();
    }

    public void commandAction(Command c, Displayable d) {
        MainUI.hsenidCommand(c, d);
    }

}
